{include file="common/header"}
<div id="app" v-cloak>
    <el-curd 
        :field="field" 
        :table-sort="{prop: 'sort', order: 'desc'}"
        :search-date="false" 
        search-keyword="请输入名称/路径搜索"
        save-title="新增菜单"
        form-label-width="100px"
        copy-authority
        table-tree
        @get-data="refresh($event)">
    </el-curd>
</div>
<script>
    new Vue({
        el: '#app',
        data() {
            return {
                field: [
                    {
                        label: '编号', 
                        prop: 'id',
                        table: false,
                    },
                    {
                        prop: 'icon', 
                        label: '菜单图标', 
                        table: false,
                        form: {
                            is: 'el-file-upload',
                            type: '.png',
                        },
                    },
                    {
                        prop: 'title', 
                        label: '菜单名称', 
                        form: {
                            placeholder: '请输入菜单名称', 
                            rules: [
                                {required: true,message: '名称不能为空'},
                            ]
                        }
                    },
                    {
                        prop: 'pid', 
                        label: '父级菜单', 
                        table: false, 
                        form: {
                            is: 'el-select',
                            child: {is: 'el-option', value: 'this'},
                            filterable: true,
                            rules: [
                                {required: true,message: '父级不能为空'},
                            ]
                        },
                    },
                    {
                        prop: 'path', 
                        label: '菜单路径',
                        form: {
                            placeholder: '请输入控制器/方法名', 
                            rules: [
                                {required: true,message: '路径不能为空'},
                            ]
                        }
                    },
                    {
                        prop: 'sort', 
                        label: '菜单排序', 
                        table: {is: 'el-input'},
                        form: {
                            type: 'number',
                            default: 0, 
                            placeholder: '降序排序，值越大越靠前'
                        },
                    },
                    {
                        prop: 'ifshow',
                        label: '是否显示',  
                        table: {is: 'el-switch',},
                        form: {
                            is: 'el-switch',
                            default: 1, 
                            activeText: '显示',
                            inactiveText: '隐藏',
                        },
                    },
                    {
                        prop: 'logwriting',
                        label: '写入日志',  
                        table: {is: 'el-switch'},
                        form: {
                            is: 'el-switch',
                            default: 1, 
                            activeText: '开启',
                            inactiveText: '关闭',
                        },
                    },
                    {
                        prop: 'type', 
                        label: '菜单类型', 
                        table: false,
                        form: {
                            is: 'el-select',
                            default: '',
                            filterable: true,
                            child: {
                                value: {:json_encode($type)}, 
                                props:{label: 'title', value: 'name'}
                            },
                        },
                    },
                ],
            }
        },
        methods: {
            refresh(res) {
                parent.parentVm.menu = res.publicMenu;
            }
        }
    })
</script>
{include file="common/footer"}